// Model.h
#pragma once

#include <string>
#include <iostream>
#include "Labyrinthe.h"
#include "PacMan.h"
#include "Config.h"

using namespace std;

class Model {
private:
	static Model *instance; // Instance du Model pour le pattern singleton

	int score;
	Labyrinthe* myLabyrinthe;
	PacMan myPacMan;
	Ghost ghost_tab[MAXGHOST];
	int nombreGhost;
	int scoreToReach;
	int currentLevel;
	string msgToShow;
	bool gameEnded;
	bool lightRed; //va permettre de faire switch� la couleur du phare du rouge au bleu
	string endMsg;
	bool pushUp, pushDown, pushRight, pushLeft;
	float zoomFactor;
	bool modeFirstPerson;
	bool selectionMode;
	bool rotation;
	bool allowFirstPersonView;
	bool drawAnimation; //permettra d'empecher de dessiner une animation
	float viewRotation;
	int cadence;
public:
	int getScore() {
		return score;
	}
	int geCadence() {
		return cadence;
	}

	void incScore(int);
	Labyrinthe *getLabyrinthe() {
		return myLabyrinthe;
	}
	int getNombreGhost() {
		return nombreGhost;
	}

	Ghost getGhost(int position) {
		return ghost_tab[position];
	}

	bool getPushUp() {
		return pushUp;
	}

	bool getPushDown() {
		return pushDown;
	}

	bool getPushLeft() {
		return pushLeft;
	}

	bool getPushRight() {
		return pushRight;
	}

	void setPushUp(bool p) {
		pushUp = p;
	}

	void setPushDown(bool p) {
		pushDown = p;
	}

	void setPushLeft(bool p) {
		pushLeft = p;
	}

	void setPushRight(bool p) {
		pushRight = p;
	}

	void setCadence(int nCadance) {
		cadence = nCadance;
	}
	void modifierPositionPacMan(int, int);
	void modifierPositionGhost(int, int, int);
	void switchSides();
	void resetGhost(int);
	void refreshGhostsDirection();
	void resetGame(); //pacman perd une vie
	void addGhost(int, int);
	void restartGame();
	void switchLevel();
	friend istream & operator >>(istream&, Model&);
	Model();
	// Pattern singleton
	static Model *getInstance();
	int getScoreToReach() {
		return scoreToReach;
	}

	void setScoreToReach(int scoreToReach);
	int getCurrentLevel() {
		return this->currentLevel;
	}

	void setCurrentLevel(int currentLevel);
	string getMsgToShow() {
		return msgToShow;
	}

	void setMsgToShow(string msgToShow);
	string getEndMsg() {
		return endMsg;
	}

	void setEndMsg(string);
	bool isGameEnded() {
		return this->gameEnded;
	}

	void setPacmanDirection(int newDirection);
	void setPacmanDirectionFirstPerson(int newDirection);
	void setGameEnded(bool);
	void setLightRed(bool);
	float getZoomFactor() const;
	void setZoomFactor(float zoomFactor);
	bool isModeFirstPerson() const;
	void setModeFirstPerson(bool modeFirstPerson);
	bool isSelectionMode() const;
	void setSelectionMode(bool isSelectionMode);
	float getViewRotation() const;
	void setViewRotation(float viewRotation);
	bool isRotation() const;
	void setRotation(bool isRotation);
	bool isAllowFirstPersonView() const;
	void setAllowFirstPersonView(bool allowFirstPersonView);
	bool isDrawAnimation() const;
	void setDrawAnimation(bool drawAnimation);
	PacMan getPacMan() const;
	void setPacmanSuperMode(bool);
	void animeBouchePacman();
	void setPacmanIdle(bool);
	void setPacmanVieRestantes(int);
	void handleEndGame(string);
	void setGhostCanLeaveJail(int, bool);
	void setGhostDeplacementX(int, int);
	void setGhostDeplacementY(int, int);
	bool isLightRed() {
		return lightRed;
	}

};
